﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MountSilverLibraryRemake
{
    public partial class AddAndModifyDialogBlue : Form
    {
        TrueSale sale;
        public AddAndModifyDialogBlue(ref TrueSale trueSale)
        {
            InitializeComponent();
            sale = trueSale;
            if(trueSale.mode!=null)
            this.mode.SelectedItem = trueSale.mode;
            this.ISBN.Text = trueSale.ISBN;
            this.number.Text = trueSale.number.ToString();
            this.finalprice.Text = trueSale.finalprice.ToString();
            if(trueSale.date!=null)
            this.date.Value = trueSale.date;
        }

        private void confirm_Click(object sender, EventArgs e)
        {
            sale.mode = this.mode.SelectedItem.ToString();
            sale.ISBN = this.ISBN.Text;
            sale.date = this.date.Value;
            try
            {
                sale.number = Convert.ToInt32(this.number.Text);
                sale.finalprice = Convert.ToDouble(this.finalprice.Text);
                this.Close();
            }
            catch(Exception error)
            {
                MessageBox.Show(error.StackTrace);
            }
        }
    }
}
